#ifndef HTTP_STREAM_SERVER_H
#define HTTP_STREAM_SERVER_H

#include <atomic>
#include <thread>


class HttpStreamServer {
public:
    HttpStreamServer(int port) : _port(port), _running(false), _server_fd(-1) {}
    virtual ~HttpStreamServer() { Stop(); }

    void Start();
    void Stop();
    bool IsRunning() const { return _running.load(); }

protected:
    // 子类重写推送逻辑
    virtual void HandleClient(int client_fd) = 0;

private:
    void AcceptLoop();

    int _port;
    int _server_fd;
    
    std::atomic<bool> _running;
    std::thread _acceptThread;
};




#endif /* HTTP_STREAM_SERVER_H */